<template>
  <div class="future">
    <div class="title">
      <p>未来30天游客趋势图</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="lineChart"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'

let lineChart = ref()

onMounted(() => {
  let myChart = echarts.init(lineChart.value)
  myChart.setOption({
    // title: {
    //   text: '未来30天游客趋势图',
    // },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      splitLine: {
        show: false,
      },
      symbol: ['none', 'arrow'], // 添加箭头到轴线末端
      data: [
        '01/01',
        '01/02',
        '01/03',
        '01/04',
        '01/05',
        '01/06',
        '01/07',
        '01/08',
        '01/09',
        '01/10',
        '01/11',
        '01/12',
        '01/13',
        '01/14',
        '01/15',
      ],
    },
    yAxis: {
      name: '(访问量)',
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
      },
      axisTick: {
        show: true,
      },
    },
    // dataZoom: [
    //   {
    //     type: 'slider', // 滑动条型
    //     show: true,
    //     xAxisIndex: 0, // 针对第一个 X 轴
    //     start: 0, // 默认显示数据的起始百分比
    //     end: 50, // 默认显示数据的结束百分比
    //   },
    //   {
    //     type: 'inside', // 支持鼠标滚轮或触摸板滑动
    //     xAxisIndex: 0,
    //     start: 0,
    //     end: 50,
    //   },
    // ],
    grid: {
      left: 50,
      right: 18,
      bottom: 40,
      top: 35,
    },
    series: {
      type: 'line',
      data: [
        5, 20, 2236, 10, 2130, 20, 129, 1284, 121, 3911, 131, 51, 2131, 4121,
        11,
      ],
      smooth: true,
      areaStyle: {
        color: {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: '#00c6ff', // 0% 处的颜色
            },
            {
              offset: 0.8,
              color: 'blue', // 100% 处的颜色
            },
          ],
        },
      },
    },
  })
})
</script>

<style lang="scss" scoped>
.future {
  width: 100%;
  height: 100%;
  background: url('../../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  // margin: 0px 30px;
  .title {
    // display: flex;
    // flex-direction: column;
    p {
      color: white;
    }
  }
  .charts {
    margin-top: 20px;
    height: calc(100% - 40px);
  }
}
</style>
